home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 25 / AACD 25.iso / AACD / Magazine / Online / QMail / patches / qmail-amiga.diff next >
Encoding:
Text File  |  1997-10-05  |  26.2 KB  |  945 lines

  1. diff -u --new-file ../qmail-1.01-unmodified/Makefile ./Makefile
  2. --- ../qmail-1.01-unmodified/Makefile    Tue Apr 15 07:05:23 1997
  3. +++ ./Makefile    Thu Oct  2 10:30:27 1997
  4. @@ -495,6 +491,9 @@
  5.      cat auto-ccld.sh find-systype.sh > find-systype
  6.      chmod 755 find-systype
  7.  
  8. +flock.o: compile flock.c
  9. +    ./compile flock.c
  10. +
  11.  fmt_str.o: \
  12.  compile fmt_str.c fmt.h fmt_str.c
  13.      ./compile fmt_str.c
  14. @@ -577,8 +576,8 @@
  15.      ./compile gfrom.c
  16.  
  17.  hasflock.h: \
  18. -tryflock.c compile load
  19. -    ( ( ./compile tryflock.c && ./load tryflock ) >/dev/null \
  20. +tryflock.c compile load flock.o
  21. +    ( ( ./compile tryflock.c && ./load tryflock flock.o ) >/dev/null \
  22.      2>&1 \
  23.      && echo \#define HASFLOCK 1 || exit 0 ) > hasflock.h
  24.      rm -f tryflock.o tryflock
  25. @@ -729,8 +728,8 @@
  26.      chmod 755 load
  27.  
  28.  lock.a: \
  29. -makelib lock_ex.o lock_exnb.o lock_un.o
  30. -    ./makelib lock.a lock_ex.o lock_exnb.o lock_un.o
  31. +makelib lock_ex.o lock_exnb.o lock_un.o flock.o
  32. +    ./makelib lock.a lock_ex.o lock_exnb.o lock_un.o flock.o
  33.  
  34.  lock_ex.o: \
  35.  compile lock_ex.c lock_ex.c lock_ex.c lock_ex.c hasflock.h lock_ex.c \
  36. @@ -1826,6 +1825,7 @@
  37.  ip.h ip.c ipalloc.h ipalloc.c select.h1 select.h2 trysysel.c ndelay.h \
  38.  ndelay.c ndelay_off.c direntry.3 direntry.h1 direntry.h2 trydrent.c \
  39.  prot.h prot.c chkshsgr.c warn-shsgr tryshsgr.c ipme.h ipme.c \
  40. +flock.c \
  41.  trysalen.c maildir.5 maildir.h maildir.c tcp-environ.5
  42.      shar -m `cat FILES` > shar
  43.      chmod 400 shar
  44. diff -u --new-file ../qmail-1.01-unmodified/TARGETS ./TARGETS
  45. --- ../qmail-1.01-unmodified/TARGETS    Tue Apr 15 07:05:23 1997
  46. +++ ./TARGETS    Thu Oct  2 10:32:09 1997
  47. @@ -351,3 +350,4 @@
  48.  envelopes.0
  49.  forgeries.0
  50.  man
  51. +flock.o
  52. diff -u --new-file ../qmail-1.01-unmodified/conf-cc ./conf-cc
  53. --- ../qmail-1.01-unmodified/conf-cc    Tue Apr 15 07:05:23 1997
  54. +++ ./conf-cc    Fri Sep 26 00:25:43 1997
  55. @@ -1,3 +1,3 @@
  56. -cc -O2
  57. +gcc -O2 -fomit-frame-pointer -resident -Wall -Dfork=vfork
  58.  
  59.  This will be used to compile .c files.
  60. diff -u --new-file ../qmail-1.01-unmodified/conf-ld ./conf-ld
  61. --- ../qmail-1.01-unmodified/conf-ld    Tue Apr 15 07:05:23 1997
  62. +++ ./conf-ld    Wed Sep 10 12:45:27 1997
  63. @@ -1,3 +1,3 @@
  64. -cc -s
  65. +gcc -s -resident
  66.  
  67.  This will be used to link .o files into an executable.
  68. diff -u --new-file ../qmail-1.01-unmodified/conf-qmail ./conf-qmail
  69. --- ../qmail-1.01-unmodified/conf-qmail    Tue Apr 15 07:05:23 1997
  70. +++ ./conf-qmail    Mon Sep 29 15:30:31 1997
  71. @@ -1,4 +1,4 @@
  72. -/var/qmail
  73. +qmail
  74.  
  75.  This is the qmail home directory. It must be a local directory, not
  76.  shared among machines. This is where qmail queues all mail messages. 
  77. diff -u --new-file ../qmail-1.01-unmodified/find-systype.sh ./find-systype.sh
  78. --- ../qmail-1.01-unmodified/find-systype.sh    Tue Apr 15 07:05:23 1997
  79. +++ ./find-systype.sh    Wed Sep 10 12:45:29 1997
  80. @@ -85,6 +85,14 @@
  81.      chip="$unamem"
  82.      kern=""
  83.      ;;
  84. +  amigaos)
  85. +    oper="$sys-$unamer-$unamev"
  86. +    arch="$unamem"
  87. +    syst=""
  88. +    # uname -p prints "unknown" :-(
  89. +    chip="`CPU | sed -e 's/System: //' -e 's/ (.*//' -e 's/ /+/'`"
  90. +    kern=""
  91. +    ;;
  92.    *)
  93.      oper="$sys-$unamer-$unamev"
  94.      arch="`arch | tr /: ..`"
  95. diff -u --new-file ../qmail-1.01-unmodified/flock.c ./flock.c
  96. --- ../qmail-1.01-unmodified/flock.c    Thu Jan  1 01:00:00 1970
  97. +++ ./flock.c    Wed Sep 10 22:35:52 1997
  98. @@ -0,0 +1,278 @@
  99. +/* flock.c : flock() and amiga_flock()
  100. +
  101. + * flock()
  102. +
  103. + * Attempts to emulate flock().
  104. + * Lock files (filename.lock) are used for this.
  105. + * open() does not support bloking behaviour, so if non-blocking behaviour
  106. + * is not requested, an attempt will be made every second until locking
  107. + * is successful.
  108. + * ChangeMode() does not support blocking behaviour, so if non-blocking
  109. + * behaviour is not requested, an attempt will be made every second until
  110. + * locking is successful.
  111. + */
  112. +
  113. +#define _KERNEL
  114. +#define _INTERNAL_FILE
  115. +
  116. +#include <dos/dos.h>
  117. +#include <dos/dosextens.h>
  118. +
  119. +#include <stdlib.h>
  120. +#include <unistd.h>
  121. +#include <sys/file.h>
  122. +#include <errno.h>
  123. +
  124. +#include <proto/dos.h>
  125. +
  126. +static fd_set locked;
  127. +static fd_set shared;
  128. +static int lock_fd [FD_SETSIZE];
  129. +
  130. +int amiga_flock(int fd, int flags);
  131. +static int create_lock (int fd, BOOL exclusive, BOOL blocking);
  132. +static int create_lock_file (char *lockname, BOOL exclusive);
  133. +
  134. +int flock (int fd, int flags)
  135. +{
  136. +  /* Create a new shared lock or turn an existing exclusive lock into
  137. +   * a shared one.
  138. +   */
  139. +  if (flags & LOCK_SH)
  140. +  {
  141. +    /* Change existing shared lock. */
  142. +    if (FD_ISSET (fd, &locked))
  143. +    {
  144. +      if (FD_ISSET (fd, &shared))
  145. +        return 0;
  146. +      else
  147. +      {
  148. +        if (-1 != amiga_flock (lock_fd [fd], ((flags & LOCK_NB) | LOCK_SH)))
  149. +        {
  150. +          FD_SET (fd, &shared);
  151. +          return (0);
  152. +        }
  153. +        else
  154. +          return (-1);
  155. +      }
  156. +    }
  157. +    /* Create new shared lock. */
  158. +    else
  159. +    {
  160. +      if (-1 != (lock_fd [fd] = create_lock (fd, FALSE, !(flags & LOCK_NB))))
  161. +      {
  162. +        FD_SET (fd, &locked);
  163. +        FD_SET (fd, &shared);
  164. +        return (0);
  165. +      }
  166. +      else
  167. +        return (-1);
  168. +    }
  169. +  }
  170. +
  171. +  /* Create a new exclusive lock or turn an existing shared lock into
  172. +   * an exclusive one.
  173. +   */
  174. +  if (flags & LOCK_EX)
  175. +  {
  176. +    /* Change existing shared lock. */
  177. +    if (FD_ISSET (fd, &locked))
  178. +    {
  179. +      if (! FD_ISSET (fd, &shared))
  180. +        return 0;
  181. +      else
  182. +      {
  183. +        if (-1 != amiga_flock (lock_fd [fd], ((flags & LOCK_NB) | LOCK_EX)))
  184. +        {
  185. +          FD_CLR (fd, &shared);
  186. +          return (0);
  187. +        }
  188. +        else
  189. +          return (-1);
  190. +      }
  191. +    }
  192. +    /* Create new exclusive lock. */
  193. +    else
  194. +    {
  195. +      if (-1 != (lock_fd [fd] = create_lock (fd, TRUE, !(flags & LOCK_NB))))
  196. +      {
  197. +        FD_SET (fd, &locked);
  198. +        FD_CLR (fd, &shared);
  199. +        return (0);
  200. +      }
  201. +      else
  202. +        return (-1);
  203. +    }
  204. +  }
  205. +
  206. +  /* Release an existing lock. */
  207. +  if (flags & LOCK_UN)
  208. +  {
  209. +    if (FD_ISSET (fd, &locked))
  210. +    {
  211. +      close (lock_fd [fd]);
  212. +      FD_CLR (fd, &locked);
  213. +    }
  214. +    return (0);
  215. +  }
  216. +
  217. +  /* No valid flags specified? */
  218. +  errno = EINVAL;
  219. +  return (-1);
  220. +}
  221. +
  222. +static int create_lock (int fd, BOOL exclusive, BOOL blocking)
  223. +{
  224. +  struct file *fp;
  225. +  char *lockname;
  226. +  int lock_fd;
  227. +
  228. +  fp = (struct file *) fcntl (fd, F_EXTERNALIZE, 0);
  229. +  if (fp == (struct file *) -1 || fp == NULL)
  230. +    return (-1);
  231. +
  232. +  if (! (( lockname = malloc (strlen (fp->f_name) + 6) )) )
  233. +  {
  234. +    errno = ENOMEM;
  235. +    return (-1);
  236. +  }
  237. +
  238. +  strcpy (lockname, fp->f_name);
  239. +  strcat (lockname, ".lock");
  240. +  errno = 0;
  241. +
  242. +  lock_fd = create_lock_file (lockname, exclusive);
  243. +
  244. +  /* If the lock failed: exit with error if non-blocking, or keep
  245. +   * retrying until success (or unrelated failure) if blocking.
  246. +   */
  247. +  while (errno == EWOULDBLOCK && blocking)
  248. +  {
  249. +    errno = 0;
  250. +    sleep (1);
  251. +    lock_fd = create_lock_file (lockname, exclusive);
  252. +  }
  253. +
  254. +  return (lock_fd);
  255. +}
  256. +
  257. +static int create_lock_file (char *lockname, BOOL exclusive)
  258. +{
  259. +  struct file *lockfile;
  260. +  int temp_errno;
  261. +  int lock_fd;
  262. +
  263. +  /* Attempt to open the lock file. To avoid deadlock (multiple tasks
  264. +   * managing to open() before at least one amiga_lock()s) on exclusive
  265. +   * locks, add O_EXCL when exclusive mode is requested.
  266. +   */
  267. +  if (-1 == (lock_fd = open (lockname, O_CREAT /* | (exclusive ? O_EXCL : 0) */ )))
  268. +  {
  269. +    if (errno == EEXIST)
  270. +      errno = EWOULDBLOCK;
  271. +    return (-1);
  272. +  }
  273. +
  274. +  /* The lock file should be deleted when it is closed. */
  275. +  lockfile = (struct file *) fcntl (lock_fd, F_EXTERNALIZE);
  276. +  if (lockfile == (struct file *) -1 || lockfile == NULL)
  277. +  {
  278. +    temp_errno = errno;
  279. +    close (lock_fd);
  280. +    errno = temp_errno;
  281. +    return (-1);
  282. +  }
  283. +  lockfile->f_flags |= FUNLINK;
  284. +
  285. +  /* Change file handle to exclusive mode if requested. */
  286. +  if (exclusive && !errno)
  287. +  {
  288. +    if (-1 == (amiga_flock (lock_fd, LOCK_EX | LOCK_NB)))
  289. +    {
  290. +      temp_errno = errno;
  291. +      close (lock_fd);
  292. +      errno = temp_errno;
  293. +      return (-1);
  294. +    }
  295. +  }
  296. +  return (lock_fd);
  297. +}
  298. +
  299. +/* amiga_flock()
  300. +
  301. + * Similar to flock(), but uses mandatory Amiga file locks instead of
  302. + * advisory locks.
  303. + * Note that because of this, there will always be at least a shared lock
  304. + * on the file with this implementation.
  305. + * ChangeMode() does not support blocking behaviour, so if non-blocking
  306. + * behaviour is not requested, an attempt will be made every second until
  307. + * locking is successful.
  308. + */
  309. +
  310. +/*
  311. +#define DEBUG_VERSION
  312. +#include <kprintf.h>
  313. +
  314. +char __flock_errorbuf[256];
  315. +char __flock_fnamebuf[1024];
  316. +char __flock_tnamebuf[1024];
  317. +*/
  318. +
  319. +/* FIXME ix_amiga.h doesn't declare this function. */
  320. +/* #include <ix_amiga.h> */
  321. +BPTR __amiga_filehandle (int fd);
  322. +
  323. +int amiga_flock (int fd, int flags)
  324. +{
  325. +  BPTR filehandle;
  326. +
  327. +  /* FIXME __amiga_filehandle() doesn't always set errno on failure :-( */
  328. +  errno = 0;
  329. +
  330. +  /* Get the filehandle (if any) associated with the file descriptor */
  331. +  if ((filehandle = __amiga_filehandle (fd)))
  332. +  {
  333. +    ULONG newmode;
  334. +    BOOL success;
  335. +
  336. +    if ((flags & LOCK_SH) || (flags & LOCK_UN))
  337. +      newmode = SHARED_LOCK;
  338. +    else if (flags & LOCK_EX)
  339. +      newmode = EXCLUSIVE_LOCK;
  340. +    else
  341. +      return (0);
  342. +
  343. +    if (flags & LOCK_NB)
  344. +    {
  345. +      if ((success = ChangeMode (CHANGE_FH, filehandle, newmode)))
  346. +        return (0);
  347. +      else
  348. +      {
  349. +        errno = EWOULDBLOCK;
  350. +/*
  351. +        Fault (IoErr(), NULL, __flock_errorbuf, 256);
  352. +        NameFromFH (filehandle, __flock_fnamebuf, 1024);
  353. +        GetProgramName (__flock_tnamebuf, 1024);
  354. +        KPrintF ("%s: ChangeMode (%s,%ld) failure: %s\n",
  355. +                 __flock_tnamebuf, __flock_fnamebuf , newmode,
  356. +                 __flock_errorbuf);
  357. +*/
  358. +        return (-1);
  359. +      }
  360. +    }
  361. +    else
  362. +    /* Blocking behaviour - loop (with delay) until success. */
  363. +    {
  364. +      while (! ChangeMode (CHANGE_FH, filehandle, newmode))
  365. +        sleep (1);
  366. +      return (0);
  367. +    }
  368. +  }
  369. +  /* Getting the file handle failed. */
  370. +  else
  371. +  {
  372. +    if (errno != EBADF)
  373. +      errno = EINVAL;
  374. +    return (-1);
  375. +  }
  376. +}
  377. diff -u --new-file ../qmail-1.01-unmodified/install.c ./install.c
  378. --- ../qmail-1.01-unmodified/install.c    Tue Apr 15 07:05:23 1997
  379. +++ ./install.c    Wed Sep 10 12:45:33 1997
  380. @@ -95,10 +95,12 @@
  381.        break;
  382.  
  383.      case 'p':
  384. +#ifndef __amigaos__
  385.        if (fifo_make(target.s,0700) == -1)
  386.          if (errno != error_exist)
  387.        strerr_die4sys(111,FATAL,"unable to mkfifo ",target.s,": ");
  388.        break;
  389. +#endif
  390.  
  391.      case 'd':
  392.        if (mkdir(target.s,0700) == -1)
  393. diff -u --new-file ../qmail-1.01-unmodified/qmail-local.c ./qmail-local.c
  394. --- ../qmail-1.01-unmodified/qmail-local.c    Tue Apr 15 07:05:23 1997
  395. +++ ./qmail-local.c    Thu Sep 25 22:10:10 1997
  396. @@ -28,6 +28,11 @@
  397.  #include "gfrom.h"
  398.  #include "auto_patrn.h"
  399.  
  400. +#ifdef __amigaos__
  401. +#include <sys/file.h>
  402. +#include <string.h>
  403. +#endif
  404. +
  405.  void err(s) char *s; { substdio_putsflush(subfderr,s); }
  406.  void soft() { _exit(111); }
  407.  void hard() { _exit(100); }
  408. @@ -44,12 +49,12 @@
  409.  void temp_open(fn) char *fn; { err("Unable to open "); err(fn); err(". (#4.2.1)\n"); soft(); }
  410.  
  411.  void temp_blankline() { err("Uh-oh: first line of .qmail file is blank. (#4.2.1)\n"); soft(); }
  412. -void temp_fofile() { err("Uh-oh: .qmail has file delivery but has x bit set. (#4.7.0)\n"); soft(); }
  413. -void temp_foprog() { err("Uh-oh: .qmail has prog delivery but has x bit set. (#4.7.0)\n"); soft(); }
  414. +void temp_fofile() { err("Uh-oh: .qmail has file delivery but has e bit set. (#4.7.0)\n"); soft(); }
  415. +void temp_foprog() { err("Uh-oh: .qmail has prog delivery but has e bit set. (#4.7.0)\n"); soft(); }
  416.  void temp_nomem() { err("Out of memory. (#4.3.0)\n"); soft(); }
  417.  void temp_chdir() { err("Unable to switch to home directory. (#4.3.0)\n"); soft(); }
  418.  void temp_homestat() { err("Unable to stat home directory. (#4.3.0)\n"); soft(); }
  419. -void temp_homesticky() { err("Home directory is sticky: user is editing his .qmail file. (#4.2.1)\n"); soft(); }
  420. +void temp_homesticky() { err("Home directory has h bit set: user is editing his .qmail file. (#4.2.1)\n"); soft(); }
  421.  void temp_homewritable() { err("Uh-oh: home directory is writable. (#4.7.0)\n"); soft(); }
  422.  void temp_qmwritable() { err("Uh-oh: .qmail file is writable. (#4.7.0)\n"); soft(); }
  423.  void temp_nfsqmail() { err("Temporary error trying to open .qmail file. (#4.3.0)\n"); soft(); }
  424. @@ -61,7 +66,7 @@
  425.  void bounce_ext() { err("Sorry, no mailbox here by that name. (#5.1.1)\n"); hard(); }
  426.  void usage() { err("qmail-local: usage: qmail-local [ -nN ] user homedir local dash ext domain sender aliasempty\n"); hard(); }
  427.  
  428. -void warn_homesticky() { err("Warning: home directory is sticky.\n"); }
  429. +void warn_homesticky() { err("Warning: home directory has h bit set.\n"); }
  430.  
  431.  int flagdoit;
  432.  int flag99;
  433. @@ -202,6 +207,7 @@
  434.  
  435.   if (seek_begin(0) == -1) temp_rewind();
  436.  
  437. +#ifndef __amigaos__
  438.   fd = open_append(fn);
  439.   if (fd == -1) temp_open(fn);
  440.  
  441. @@ -211,6 +217,27 @@
  442.   alarm(0);
  443.   sig_alarmdefault();
  444.  
  445. +#else /* __amigaos__ */
  446. + /* Attempt a mandatory exclusive lock for upto 30 seconds. */
  447. + {
  448. +   int c;
  449. +
  450. +   for (c = 30, flaglocked = 0; !flaglocked && c >= 0; c--)
  451. +   {
  452. +     if (-1 != (fd = open_append(fn)))
  453. +     {
  454. +       if (!(flaglocked = (-1 != amiga_flock (fd, LOCK_EX | LOCK_NB))))
  455. +       {
  456. +         close (fd);
  457. +         if (c != 0) sleep (1);
  458. +       }
  459. +     }
  460. +   }
  461. +   if (!flaglocked)
  462. +     temp_slowlock();
  463. + }
  464. +#endif /* __amigaos__ */
  465. +
  466.   seek_end(fd);
  467.   pos = seek_cur(fd);
  468.  
  469. @@ -476,7 +503,11 @@
  470.   if (!(aliasempty = *argv++)) usage();
  471.   if (*argv) usage();
  472.  
  473. +#ifdef __amigaos__
  474. + if (strchr (homedir, ':') <= &homedir[0]) usage();
  475. +#else
  476.   if (homedir[0] != '/') usage();
  477. +#endif
  478.   if (chdir(homedir) == -1) temp_chdir();
  479.   checkhome();
  480.  
  481. @@ -545,8 +576,13 @@
  482.   if (!stralloc_copys(&dashext,dash)) temp_nomem();
  483.   if (!stralloc_cats(&dashext,ext)) temp_nomem();
  484.   for (i = 0;i < dashext.len;++i)
  485. +#ifdef __amigaos__
  486. +   if (dashext.s[i] == '.' || dashext.s[i] == ':' || dashext.s[i] == '/')
  487. +     dashext.s[i] = ';';
  488. +#else
  489.     if (dashext.s[i] == '.')
  490.       dashext.s[i] = ':';
  491. +#endif
  492.   case_lowerb(dashext.s,dashext.len);
  493.  
  494.   extx = ext;
  495. @@ -602,8 +638,8 @@
  496.   for (j = 0;j < cmds.len;++j)
  497.     if (cmds.s[j] == '\n')
  498.      {
  499. -     switch(cmds.s[i]) { case '#': case '.': case '/': case '|': break;
  500. -       default: ++numforward; }
  501. +     switch(cmds.s[i]) { case '&': ++numforward; break;
  502. +       default: break; }
  503.       i = j + 1;
  504.      }
  505.  
  506. @@ -628,17 +664,6 @@
  507.       temp_blankline();
  508.         case '#':
  509.           break;
  510. -       case '.':
  511. -       case '/':
  512. -     ++count_file;
  513. -     if (flagforwardonly) temp_fofile();
  514. -     if (cmds.s[k - 1] == '/')
  515. -           if (flagdoit) maildir(cmds.s + i);
  516. -           else sayit("maildir ",cmds.s + i,k - i);
  517. -     else
  518. -           if (flagdoit) mailfile(cmds.s + i);
  519. -           else sayit("mbox ",cmds.s + i,k - i);
  520. -         break;
  521.         case '|':
  522.       ++count_program;
  523.       if (flagforwardonly) temp_foprog();
  524. @@ -651,11 +676,21 @@
  525.       break;
  526.         case '&':
  527.           ++i;
  528. -       default:
  529.       ++count_forward;
  530.           if (flagdoit) recips[numforward++] = cmds.s + i;
  531.           else sayit("forward ",cmds.s + i,k - i);
  532.           break;
  533. +       default:
  534. +     ++count_file;
  535. +     if (flagforwardonly) temp_fofile();
  536. +     if (cmds.s[k - 1] == '/')
  537. +           if (flagdoit) maildir(cmds.s + i);
  538. +           else sayit("maildir ",cmds.s + i,k - i);
  539. +     else
  540. +           if (flagdoit) mailfile(cmds.s + i);
  541. +           else sayit("mbox ",cmds.s + i,k - i);
  542. +         break;
  543. +
  544.        }
  545.       i = j + 1;
  546.       if (flag99) break;
  547. --- ../qmail-1.01-unmodified/qmail-newu.c    Tue Apr 15 07:05:23 1997
  548. +++ qmail-newu.c    Sun Oct  5 16:14:54 1997
  549. @@ -94,7 +94,7 @@
  550.      if (!match) die_format();
  551.  
  552.      if (byte_chr(line.s,line.len,'\0') < line.len) die_format();
  553. -    i = byte_chr(line.s,line.len,':');
  554. +    i = byte_chr(line.s,line.len,'|');
  555.      if (i == line.len) die_format();
  556.      if (i == 0) die_format();
  557.      if (!stralloc_copys(&key,"!")) die_nomem();
  558. @@ -115,7 +115,7 @@
  559.  
  560.      numcolons = 0;
  561.      for (i = 0;i < data.len;++i)
  562. -      if (data.s[i] == ':') {
  563. +      if (data.s[i] == '|') {
  564.      data.s[i] = 0;
  565.      if (++numcolons == 6)
  566.        break;
  567. --- ../qmail-1.01-unmodified/qmail-pw2u.9    Tue Apr 15 07:05:23 1997
  568. +++ qmail-pw2u.9    Sun Oct  5 22:33:21 1997
  569. @@ -20,7 +20,7 @@
  570.  Each line has the format
  571.  
  572.  .EX
  573. -   user:password:uid:gid:gecos:home:shell
  574. +   user|password|uid|gid|gecos|home|shell
  575.  .EE
  576.  
  577.  where
  578. @@ -121,7 +121,7 @@
  579.  Each line has the form
  580.  
  581.  .EX
  582. -   user:mailname1:mailname2:...
  583. +   user|mailname1|mailname2|...
  584.  .EE
  585.  
  586.  The addresses
  587. @@ -155,7 +155,7 @@
  588.  Each line has the form
  589.  
  590.  .EX
  591. -   sub:user:pre:
  592. +   sub|user|pre:
  593.  .EE
  594.  
  595.  .I sub
  596. --- ../qmail-1.01-unmodified/qmail-pw2u.c    Tue Apr 15 07:05:23 1997
  597. +++ qmail-pw2u.c    Sun Oct  5 16:15:25 1997
  598. @@ -99,19 +99,19 @@
  599.  
  600.    if (byte_chr(line.s,line.len,'\0') < line.len) return;
  601.  
  602. -  x = line.s; xlen = line.len; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  603. +  x = line.s; xlen = line.len; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  604.    if (!stralloc_copyb(&user,x,i)) die_nomem();
  605.    if (!stralloc_0(&user)) die_nomem();
  606. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  607. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  608. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  609. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  610.    if (!stralloc_copyb(&uidstr,x,i)) die_nomem();
  611.    if (!stralloc_0(&uidstr)) die_nomem();
  612.    scan_ulong(uidstr.s,&uid);
  613. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  614. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  615.    if (!stralloc_copyb(&gidstr,x,i)) die_nomem();
  616.    if (!stralloc_0(&gidstr)) die_nomem();
  617. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  618. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  619. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  620. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  621.    if (!stralloc_copyb(&home,x,i)) die_nomem();
  622.    if (!stralloc_0(&home)) die_nomem();
  623.  
  624. @@ -165,10 +165,10 @@
  625.      mailnames = user.s;
  626.  
  627.    for (;;) {
  628. -    while (*mailnames == ':') ++mailnames;
  629. +    while (*mailnames == '|') ++mailnames;
  630.      if (!*mailnames) break;
  631.  
  632. -    i = str_chr(mailnames,':');
  633. +    i = str_chr(mailnames,'|');
  634.  
  635.      if (substdio_puts(subfdout,"=") == -1) die_write();
  636.      if (substdio_put(subfdout,mailnames,i) == -1) die_write();
  637. @@ -196,12 +196,12 @@
  638.    unsigned int xlen;
  639.    char *uugh;
  640.  
  641. -  x = line.s; xlen = line.len; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  642. +  x = line.s; xlen = line.len; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  643.    if (!stralloc_copyb(&sub,x,i)) die_nomem();
  644. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  645. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  646.    uugh = constmap(&mapuser,x,i);
  647.    if (!uugh) die_user(x,i);
  648. -  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,':'); if (i == xlen) return;
  649. +  ++i; x += i; xlen -= i; i = byte_chr(x,xlen,'|'); if (i == xlen) return;
  650.  
  651.    if (substdio_puts(subfdout,"=") == -1) die_write();
  652.    if (substdio_put(subfdout,sub.s,sub.len) == -1) die_write();
  653. diff -u --new-file ../qmail-1.01-unmodified/qmail-queue.c ./qmail-queue.c
  654. --- ../qmail-1.01-unmodified/qmail-queue.c    Tue Apr 15 07:05:23 1997
  655. +++ ./qmail-queue.c    Wed Sep 10 12:45:41 1997
  656. @@ -249,6 +249,15 @@
  657.  
  658.   if (link(intdfn,todofn) == -1) die(106);
  659.  
  660. +#ifdef __amigaos__
  661. + /* Close files and force uid/gid to be set. */
  662. + close (messfd);
  663. + close (intdfd);
  664. + if (chown (todofn, auto_uidq, auto_gidq) == -1) die (105);
  665. + if (chown (intdfn, auto_uidq, auto_gidq) == -1) die (105);
  666. + if (chown (messfn, auto_uidq, auto_gidq) == -1) die (105);
  667. +#endif
  668. +
  669.   triggerpull();
  670.   die(0);
  671.  }
  672. diff -u --new-file ../qmail-1.01-unmodified/qmail-send.c ./qmail-send.c
  673. --- ../qmail-1.01-unmodified/qmail-send.c    Tue Apr 15 07:05:23 1997
  674. +++ ./qmail-send.c    Thu Oct  2 08:49:29 1997
  675. @@ -32,6 +32,26 @@
  676.  #include "fmtqfn.h"
  677.  #include "readsubdir.h"
  678.  
  679. +#ifdef __amigaos__
  680. +#define timeval amigaos_timeval
  681. +#include <exec/types.h>
  682. +#include <dos/dos.h>
  683. +#include <proto/exec.h>
  684. +#undef timeval
  685. +#include <sys/signal.h>
  686. +#include <stdio.h> /* Needed by ix(_amiga).h. */
  687. +/* Hack to find out if include files are for ixemul version 47+ or not. */
  688. +#define __pos__
  689. +#ifndef CTOBPTR
  690. +#define ix_select extselect
  691. +#include <ix_amiga.h>
  692. +#else
  693. +#define __INCLV47__
  694. +#include <ix.h>
  695. +#endif
  696. +#undef __pos__
  697. +#endif
  698. +
  699.  /* critical timing feature #1: if not triggered, do not busy-loop */
  700.  /* critical timing feature #2: if triggered, respond within fixed time */
  701.  /* important timing feature: when triggered, respond instantly */
  702. @@ -1266,8 +1286,12 @@
  703.   if (*wakeup > nexttodorun) *wakeup = nexttodorun;
  704.  }
  705.  
  706. +#ifndef __amigaos
  707.  void todo_do(rfds)
  708.  fd_set *rfds;
  709. +#else
  710. +void todo_do (unsigned long signals)
  711. +#endif
  712.  {
  713.   struct stat st;
  714.   substdio ss; int fd;
  715. @@ -1293,7 +1317,11 @@
  716.  
  717.   if (!tododir)
  718.    {
  719. +#ifndef __amigaos__
  720.     if (!trigger_pulled(rfds))
  721. +#else
  722. +   if (!trigger_pulled (signals))
  723. +#endif
  724.       if (recent < nexttodorun)
  725.         return;
  726.     trigger_set();
  727. @@ -1553,6 +1581,10 @@
  728.   int nfds;
  729.   struct timeval tv;
  730.   int c;
  731. +#ifdef __amigaos__
  732. + long signalmask;
  733. + int selret;
  734. +#endif
  735.  
  736.   if (chdir(auto_qmail) == -1)
  737.    { log1("alert: cannot start: unable to switch to home directory\n"); _exit(111); }
  738. @@ -1560,6 +1592,13 @@
  739.    { log1("alert: cannot start: unable to read controls\n"); _exit(111); }
  740.   if (chdir("queue") == -1)
  741.    { log1("alert: cannot start: unable to switch to queue directory\n"); _exit(111); }
  742. +#ifdef __amigaos__
  743. + /* Clear the signals we use before use. */
  744. + SetSignal (0UL, SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);
  745. + /* Cause Ctrl-C (from e.g. the Break command) do terminate qmail.
  746. +  * Ctrl-C is mapped to SIGINT by default, so map SIGINT to SIGTERM). */
  747. + signal (SIGINT, sigterm);
  748. +#endif
  749.   sig_pipeignore();
  750.   sig_termcatch(sigterm);
  751.   sig_alarmcatch(sigalrm);
  752. @@ -1630,18 +1669,46 @@
  753.     else tv.tv_sec = wakeup - recent + SLEEP_FUZZ;
  754.     tv.tv_usec = 0;
  755.  
  756. +#ifdef __amigaos__
  757. +   signalmask = SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D |
  758. +                SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F;
  759. +   selret = ix_select (nfds, &rfds, &wfds, (fd_set *) 0UL, &tv, &signalmask);
  760. +   if (selret == -1 && !(signalmask & SIGBREAKF_CTRL_D))
  761. +#else
  762.     if (select(nfds,&rfds,&wfds,(fd_set *) 0,&tv) == -1)
  763. +#endif
  764.       if (errno == error_intr)
  765. +#ifndef __amigaos__
  766.         ;
  767. +#else
  768. +     {
  769. +       /* Map some Amiga signals to Un*x ones
  770. +          (Ctrl-C is mapped to SIGINT elsewhere). */
  771. +       if (signalmask & SIGBREAKF_CTRL_E) sigalrm ();
  772. +       if (signalmask & SIGBREAKF_CTRL_F) sighup ();
  773. +#endif /* __amigaos__ */
  774. +     }
  775.       else
  776.         log1("warning: trouble in select\n");
  777.     else
  778.      {
  779.       recent = now();
  780.  
  781. +#ifdef __amigaos__
  782. +     if (selret == -1 && (signalmask & SIGBREAKF_CTRL_D))
  783. +     {
  784. +       /* This prevents qmail-send from hanging (but don't ask me why). */
  785. +       FD_ZERO (&rfds);
  786. +       FD_ZERO (&wfds);
  787. +     }
  788. +#endif
  789.       comm_do(&wfds);
  790.       del_do(&rfds);
  791. +#ifdef __amigaos__
  792. +     todo_do(signalmask);
  793. +#else
  794.       todo_do(&rfds);
  795. +#endif
  796.       pass_do();
  797.       cleanup_do();
  798.      }
  799. diff -u --new-file ../qmail-1.01-unmodified/qsutil.c ./qsutil.c
  800. --- ../qmail-1.01-unmodified/qsutil.c    Tue Apr 15 07:05:23 1997
  801. +++ ./qsutil.c    Thu Sep 25 23:48:34 1997
  802. @@ -2,6 +2,7 @@
  803.  #include "readwrite.h"
  804.  #include "substdio.h"
  805.  #include "qsutil.h"
  806. +#include "error.h"
  807.  
  808.  static stralloc foo = {0};
  809.  
  810. @@ -19,10 +20,16 @@
  811.   substdio_putsflush(&sserr,s1);
  812.   substdio_putsflush(&sserr,s2);
  813.   substdio_putsflush(&sserr,s3); }
  814. +void log5(s1,s2,s3,s4,s5) char *s1; char *s2; char *s3; char *s4; char *s5; {
  815. + substdio_putsflush(&sserr,s1);
  816. + substdio_putsflush(&sserr,s2);
  817. + substdio_putsflush(&sserr,s3);
  818. + substdio_putsflush(&sserr,s4);
  819. + substdio_putsflush(&sserr,s5); }
  820.  void nomem() { log1("alert: out of memory, sleeping...\n"); sleep(10); }
  821.  
  822.  void pausedir(dir) char *dir;
  823. -{ log3("alert: unable to opendir ",dir,", sleeping...\n"); sleep(10); }
  824. +{ log5("alert: unable to opendir ",dir," (",strerror(errno),"), sleeping...\n"); sleep(10); }
  825.  
  826.  static int issafe(ch) char ch;
  827.  {
  828. diff -u --new-file ../qmail-1.01-unmodified/trigger.c ./trigger.c
  829. --- ../qmail-1.01-unmodified/trigger.c    Tue Apr 15 07:05:23 1997
  830. +++ ./trigger.c    Fri Sep 26 20:43:14 1997
  831. @@ -1,15 +1,19 @@
  832.  #include "select.h"
  833. -#include "open.h"
  834.  #include "trigger.h"
  835. +#ifndef __amigaos__
  836. +#include "open.h"
  837.  #include "hasnpbg1.h"
  838. -
  839.  static int fd = -1;
  840.  #ifdef HASNAMEDPIPEBUG1
  841.  static int fdw = -1;
  842.  #endif
  843. +#else /* if __amigaos__ */
  844. +#include <dos/dos.h>
  845. +#endif /* __amigaos__ */
  846.  
  847.  void trigger_set()
  848.  {
  849. +#ifndef __amigaos__
  850.   if (fd != -1)
  851.     close(fd);
  852.  #ifdef HASNAMEDPIPEBUG1
  853. @@ -20,22 +24,35 @@
  854.  #ifdef HASNAMEDPIPEBUG1
  855.   fdw = open_write("lock/trigger");
  856.  #endif
  857. +#endif /* ! __amigaos__ */
  858.  }
  859.  
  860.  void trigger_selprep(nfds,rfds)
  861.  int *nfds;
  862.  fd_set *rfds;
  863.  {
  864. +#ifndef __amigaos__
  865.   if (fd != -1)
  866.    {
  867.     FD_SET(fd,rfds);
  868.     if (*nfds < fd + 1) *nfds = fd + 1;
  869.    }
  870. +#endif
  871.  }
  872.  
  873. +#ifndef __amigaos__
  874.  int trigger_pulled(rfds)
  875.  fd_set *rfds;
  876.  {
  877.   if (fd != -1) if (FD_ISSET(fd,rfds)) return 1;
  878.   return 0;
  879.  }
  880. +#else
  881. +int trigger_pulled (unsigned long signals)
  882. +{
  883. +  if (signals & SIGBREAKF_CTRL_D)
  884. +    return 1;
  885. +  else
  886. +    return 0;
  887. +}
  888. +#endif
  889. diff -u --new-file ../qmail-1.01-unmodified/triggerpull.c ./triggerpull.c
  890. --- ../qmail-1.01-unmodified/triggerpull.c    Tue Apr 15 07:05:23 1997
  891. +++ ./triggerpull.c    Fri Sep 26 20:33:07 1997
  892. @@ -1,9 +1,21 @@
  893. +#ifndef __amigaos__
  894.  #include "ndelay.h"
  895.  #include "open.h"
  896. +#else
  897. +#include <exec/types.h>
  898. +#include <exec/tasks.h>
  899. +#include <dos/dos.h>
  900. +#include <dos/dosextens.h>
  901. +#include <proto/exec.h>
  902. +#include <proto/dos.h>
  903. +#include <string.h>
  904. +#include <signal.h>
  905. +#endif /* __amigaos__ */
  906.  #include "triggerpull.h"
  907.  
  908.  void triggerpull()
  909.  {
  910. +#ifndef __amigaos__
  911.   int fd;
  912.  
  913.   fd = open_write("lock/trigger");
  914. @@ -13,4 +25,30 @@
  915.     write(fd,"",1); /* if it fails, bummer */
  916.     close(fd);
  917.    }
  918. +#else /* __amigaos__ */
  919. +  /* This is the ugly part. */
  920. +  ULONG maxCLI, i;
  921. +  struct Process *proc;
  922. +  struct CommandLineInterface *cli;
  923. +  UBYTE *cmdName;
  924. +  int omask;
  925. +
  926. +  /* Disable Un*x signals. */
  927. +  omask = sigsetmask (~0);
  928. +  /* Forbid preemptive task switching. :-( */
  929. +  Forbid ();
  930. +  maxCLI = MaxCli ();
  931. +  /* Send a Ctrl-D signal to all processes named "qmail-send". */
  932. +  for (i = 1UL; i <= maxCLI; i++)
  933. +    if ((proc = FindCliProc (i)))
  934. +      if ((cli = BADDR (proc->pr_CLI)))
  935. +        if ((cmdName = BADDR (cli->cli_CommandName)))
  936. +          if (cmdName[0] > 0 && 0 == strncmp ("qmail-send", &cmdName[1], cmdName[0]))
  937. +          {
  938. +            Signal ((struct Task *) proc, SIGBREAKF_CTRL_D);
  939. +          }
  940. +
  941. +  Permit ();
  942. +  sigsetmask (omask);
  943. +#endif /* __amigaos__ */
  944.  }
  945.